
#apt install linux-image-5.15.0-25-generic/jammy -y
#apt install linux-headers-5.15.0-25-generic -y
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
apt install systemd -y

apt install conntrack mtd-utils iptables rsyslog udev bc flex dbus bison libncurses-dev file kmod openssh-server openssh-client netplan.io man vim wget net-tools sysstat tmux less sudo git iputils-ping -y


cat > /etc/netplan/50-cloud-init.yaml <<EOF
network:
    ethernets:
        enp0s1:
            dhcp4: yes
    version: 2
EOF

cat > /etc/networks <<EOF
# symbolic names for networks, see networks(5) for more information
link-local 169.254.0.0

# The primary network interface
allow-hotplug enp0s1
iface enp0s1 inet dhcp
#
EOF

cat > /etc/fstab <<EOF
# UNCONFIGURED FSTAB FOR BASE SYSTEM

kmod_mount    /mnt  9p trans=virtio  0 0
EOF

cd /usr/src/linux/source


#ARCH=arm64
#CROSS_COMPILE=aarch64-arm-linux-gnu- 

#TODO - a better way to do this is to cp .config file
make defconfig
make modules_prepare

rm /usr/src/linux/Makefile

cat > /usr/src/linux/Makefile <<EOF
# Automatically generated by /home/coresat/qemu_aarch64_kernel/linux-6.8.1/Makefile: don't edit
include ./source/Makefile
EOF

rm -rf /usr/src/linux/scripts
cp -r scripts /usr/src/linux
#make mrproper

passwd root

umount /dev/pts/ /dev/ /proc/ /sys

exit
